import { reactive, ref, watch } from 'vue'

const useForm = function<T>(
  emit: (event: string, ...args: any[]) => void,
  formId?: string,
  findFn?: (formId: string) => Promise<any>) {
  const state = reactive({
    form: {} as T
  })
  const formRef = ref<any>(null)
  const closeDialog = () => emit('update:visible', false)

  return {
    closeDialog,
    state,
    formRef
  }
}

export default useForm
